import api from '../index'
import type { DataList, EntDevices, EntListRes, QueryData, RowListRes, TreeData } from './types/ent'
import type { ChanWuRow, CreateFormData, EditFormData, JianCeRow, MainTableRow, ReusePartsRow, ReuseRow } from '@/views/document/manager/create/create'

export default {
  // 登录
  GetEnterprises: (data: QueryData) => api<EntListRes>({
    method: 'post',
    url: '/Env/GetEnterprises',
    data,
  }),
  // 环保局
  GetNEIndustrys: () =>
    api<TreeData[]>({
      url: `/Business/GetNEIndustrys`,
      method: 'post',
    }),
  // 管理机构
  GetEnvOrgs: () =>
    api<TreeData[]>({
      url: `/Env/GetEnvOrgs`,
      method: 'post',
    }),

  GetDistricts: () => api<DataList>({
    url: `/Business/GetDistricts`,
    method: 'post',
  }),
  GetEnterpriseAndDeviceNums: (data: QueryData) => api<RowListRes>({
    url: `/Env/GetEnterpriseAndDeviceNums`,
    method: 'post',
    data,
  }),
  EnterpriseAdd: (data: { enterprise: CreateFormData }) => api<EditFormData>({
    url: `/Env/Enterprise/Add`,
    method: 'post',
    data,
  }),
  // 编辑企业
  EnterpriseUpdate: (data: { enterpriseObjID: string, enterprise: EditFormData }) => api<EditFormData>({
    url: `/Env/Enterprise/Update`,
    method: 'post',
    data,
  }),
  // 删除企业
  entDelete: (data: { enterpriseObjID: string }) => api({
    url: `/Env/Enterprise/Delete`,
    method: 'post',
    data,
  }),
  GetAccount: (data: { enterpriseObjID: string }) => api({
    url: `/Env/Enterprise/GetAccount`,
    method: 'post',
    data,
  }),
  SetAccount: (data: { enterpriseObjID: string, accounts: any[] }) => api({
    url: `/Env/Enterprise/SetAccount`,
    method: 'post',
    data,
  }),
  GetProduceReuse: (data: { enterpriseObjID: string }) => api<EntDevices>({
    url: `/Env/GetProduceReuse`,
    method: 'post',
    data,
  }),
  AddElectricDevice: (data: { enterpriseObjID: string, electricDevice: MainTableRow }) => api({
    url: `/Env/Enterprise/AddElectricDevice`,
    method: 'post',
    data,
  }),
  UpdateElectricDevice: (data: { electricDeviceObjID: string, electricDevice: MainTableRow }) => api({
    url: `/Env/Enterprise/UpdateElectricDevice`,
    method: 'post',
    data,
  }),
  DeleteElectricDevice: (data: { electricDeviceObjID: string, enterpriseObjID: string }) => api({
    url: `/Env/Enterprise/DeleteElectricDevice`,
    method: 'post',
    data,
  }),
  // 新增生产设施
  ProduceAdd: (data: { enterpriseObjID: string, produce: ChanWuRow }) => api({
    url: `/Env/Produce/Add`,
    method: 'post',
    data,
  }),
  // 修改生产设施
  ProduceUpdate: (data: { produceObjID: string, produce: ChanWuRow }) => api({
    url: `/Env/Produce/Update`,
    method: 'post',
    data,
  }),
  ProduceDelete: (data: { produceObjID: string }) => api({
    url: `/Env/Produce/Delete`,
    method: 'post',
    data,
  }),
  // 新增产污设施电表
  ProduceAddElectricDevice: (data: { produceObjID: string, electricDevice: JianCeRow }) => api({
    url: `/Env/Produce/AddElectricDevice`,
    method: 'post',
    data,
  }),
  // 修改产污设施电表
  ProduceUpdateElectricDevice: (data: { electricDeviceObjID: string, electricDevice: JianCeRow }) => api({
    url: `/Env/Produce/UpdateElectricDevice`,
    method: 'post',
    data,
  }),
  // 删除产污设施电表
  ProduceDeleteElectricDevice: (data: { electricDeviceObjID: string, produceObjID: string }) => api({
    url: `/Env/Produce/DeleteElectricDevice`,
    method: 'post',
    data,
  }),
  // 新增治理设施
  ReuseAdd: (data: { enterpriseObjID: string, reuse: ReuseRow }) => api<ReuseRow>({
    url: `/Env/Reuse/Add`,
    method: 'post',
    data,
  }),
  // 绑定关系
  SetBindProduces: (data: { reuseObjID: string, produceObjIDs: string[] }) => api({
    url: `/Env/Reuse/SetBindProduces`,
    method: 'post',
    data,
  }),
  // 修改治理设施
  ReuseUpdate: (data: { reuseObjID: string, reuse: ReuseRow }) => api<ReuseRow>({
    url: `/Env/Reuse/Update`,
    method: 'post',
    data,
  }),
  // 删除治理设施
  ReuseDelete: (data: { reuseObjID: string }) => api({
    url: `/Env/Reuse/Delete`,
    method: 'post',
    data,
  }),
  // 新增治理环节
  AddReusePart: (data: { reuseObjID: string, reusePart: ReusePartsRow }) => api({
    url: `/Env/Reuse/AddReusePart`,
    method: 'post',
    data,
  }),
  // 修改治理环节
  UpdateReusePart: (data: { reusePartObjID: string, reusePart: ReusePartsRow }) => api({
    url: `/Env/Reuse/UpdateReusePart`,
    method: 'post',
    data,
  }),
  // 删除治理环节
  DeleteReusePart: (data: { reusePartObjID: string }) => api({
    url: `/Env/Reuse/DeleteReusePart`,
    method: 'post',
    data,
  }),
  ReuseAddElectricDevice: (data: { reusePartObjID: string, electricDevice: JianCeRow }) => api({
    url: `/Env/Reuse/AddElectricDevice`,
    method: 'post',
    data,
  }),
  ReuseUpdateElectricDevice: (data: { electricDeviceObjID: string, electricDevice: JianCeRow }) => api({
    url: `/Env/Reuse/UpdateElectricDevice`,
    method: 'post',
    data,
  }),
  ReuseDeleteElectricDevice: (data: { electricDeviceObjID: string, reusePartObjID: string }) => api({
    url: `/Env/Reuse/DeleteElectricDevice`,
    method: 'post',
    data,
  }),
  // 创建MN
  CreateMN: (data: { enterpriseObjID: string }) => api<string>({
    url: `/Env/Enterprise/CreateMN`,
    method: 'post',
    data,
  }),
  // 创建点位编码
  CreatePointCode: (data: { parentObjID: string }) => api<string>({
    url: `/Env/Enterprise/CreatePointCode`,
    method: 'post',
    data,
  }),
  // 运维公司
  GetOwnerOrgs: () => api<TreeData[]>({
    url: `/Obj/OwnerOrg/GetOwnerOrgs`,
    method: 'post',
  }),
  // 运行状态
  GetDeviceStates: () => api<DataList>({
    url: `/Obj/Device/GetDeviceStates`,
    method: 'post',
  }),
  // 环保局统计数据
  GetEnvOrgStat: (data: { envOrgObjID: string }) => api<any>({
    url: `/Env/Data/GetEnvOrgStat`,
    method: 'post',
    data,
  }),
  // 企业统计
  GetEnterpriseStat: (data: { enterpriseObjIDs: string[] }) => api<any>({
    url: `/Env/Data/GetEnterpriseStat`,
    method: 'post',
    data,
  }),
  // 企业统计
  GetEnterprisePowerDatas: (data: { enterpriseObjIDs: string[], startTime: string, endTime: string }) => api<any>({
    url: `/Env/Data/GetEnterprisePowerDatas`,
    method: 'post',
    data,
  }),
  // 责任单位可用环保局
  GetOwnerOrgUsableEnvOrg: (data: { ownerOrgObjID: string }) => api<any>({
    url: `/Obj/OwnerOrg/GetOwnerOrgUsableEnvOrg`,
    method: 'post',
    data,
  }),
  // 责任单位可用环保局
  SetOwnerOrgUsableEnvOrg: (data: { ownerOrgObjID: string, envOrgObjIDs: string[] }) => api<any>({
    url: `/Obj/OwnerOrg/SetOwnerOrgUsableEnvOrg`,
    method: 'post',
    data,
  }),
  // 责任单位可用环保局
  GetEnvOrgUsableOwnerOrg: (data: { envOrgObjID: string }) => api<any>({
    url: `/Obj/EnvOrg/GetEnvOrgUsableOwnerOrg`,
    method: 'post',
    data,
  }),
  // 责任单位可用环保局
  SetEnvOrgUsableOwnerOrg: (data: { envOrgObjID: string, ownerOrgObjIDs: string[] }) => api<any>({
    url: `/Obj/EnvOrg/SetEnvOrgUsableOwnerOrg`,
    method: 'post',
    data,
  }),
  // 增加责任单位
  AddOwnerOrg: (data: any) => api<any>({
    url: `/Obj/OwnerOrg/AddOwnerOrg`,
    method: 'post',
    data,
  }),
  // 修改责任单位
  UpdateOwnerOrg: (data: any) => api<any>({
    url: `/Obj/OwnerOrg/UpdateOwnerOrg`,
    method: 'post',
    data,
  }),
  // 删除责任单位
  DeleteOwnerOrg: (data: any) => api<any>({
    url: `/Obj/OwnerOrg/DeleteOwnerOrg`,
    method: 'post',
    data,
  }),
  // 增加环保局
  AddEnvOrg: (data: any) => api<any>({
    url: `/Obj/EnvOrg/AddEnvOrg`,
    method: 'post',
    data,
  }),
  // 删除环保局
  DeleteEnvOrg: (data: any) => api<any>({
    url: `/Obj/EnvOrg/DeleteEnvOrg`,
    method: 'post',
    data,
  }),
  // 修改环保局
  UpdateEnvOrg: (data: any) => api<any>({
    url: `/Obj/EnvOrg/UpdateEnvOrg`,
    method: 'post',
    data,
  }),
  // 获取日志分类
  GetLogClassifys: () => api<any>({
    url: `/System/GetLogClassifys`,
    method: 'post',
  }),
  // 日志列表
  GetLogs: (data: { startTime: string | null, endTime: string | null, logTypes: string[], filters: any, pageSize: number, pageNum: number }) => api<any>({
    url: `/Env/Data/GetLogs`,
    method: 'post',
    data,
  }),

}
